public class test_4 {
    public static void main(String[] args) {
        int n = 1000;
        for (int i = 2; i <= n; i++) {
            if (isPerfectNumber(i)) {
                System.out.println(i);
            }
        }
    }

    public static boolean isPerfectNumber(int num) {
        int sum = 1;
        for (int i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                int factor = num / i;
                if (i != factor) {
                    sum += i + factor;
                } else {
                    sum += i;
                }
            }
        }
        return sum == num;
    }
}